<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			#container {
				display: none;
			}
		</style>
		<link rel="stylesheet" href="../css/nprogress.css" />
		<script type="text/javascript" src="../js/jquery.js"></script>
		<script type="text/javascript" src="../js/nprogress.js"></script>
		<script type="text/javascript" src="jquery.pjax.js"></script>
		<script>
			$(function() {
				var cur = "http://www.baidu.com/site/blog/32/asd";
				var m = cur.match(/(\/site\/blog\/[0-9]+)/);
				console.info(cur.replace(/(\/site\/blog\/[0-9]+)/, "$1"));
				console.info("---------------------")
				console.info(m.length + "  " + m[1]);
				var s = m[0];
				var $a = $('a[href*="' +s+'"]');
				console.info($a.size());
				$a.text("hahah")
				
				
				
				
				var containerId = '#container';
				
				
				var reg = /.*ss(\d+)rr.*/;
				var str = "ss12345rr3432re232";
				str = str.replace(reg, "$1");
				console.info(str);

				//打开页面时加载进度条。
				NProgress.start();
				window.onload = function() {
					NProgress.done();
					$(containerId).stop(true, true).fadeIn();
				}

				/**
				 * 捕获 a 事件，当点击后要在 300 毫秒以后才会跳转。
				 */
				$(document).on('click', 'a[target!=_blank][data-pjax!=false]', function() {
					$(containerId).fadeOut();
					NProgress.start();
					var url = $(this).attr("href");
					setTimeout(function() {
						$.pjax({
							url: url,
							container: containerId,
							//fragment: containerId,
							timeout: 8000
						});
					}, 300);

					return false;
				});

				$(document).on('pjax:complete', function() {
					//加载进度条完成。
					NProgress.done();
					$(containerId).stop(true, true).fadeIn();
				});

			});
		</script>

	</head>

	<body>
		<h1>My Site</h1>
		<a href="#" class="btn">aa
			<i>555</i>
		</a>
		<br> Go to
		<hr />
		<a class="aa" href="other.html?p=3" data-pjax="#container">next page</a>.<br>
		<hr />
		<a class="aa" href="some.html?p=1" data-pjax="#container">somepage</a>.<br>
		<a class="aa" href="some/other.html?p=2">somepage</a>.<br>
		
		<a href="http://www.baidu.com/site/blog/32/asd">baidu</a><br>
		<div class="container" id="container">

		</div>
	</body>

</html>